﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Company.Merchandising.BusinessLayer.DataEntities;

namespace Company.Merchandising.DataAccessLayer.DataAccessCommon
{
	public class DACCity : DACBase
	{
		public DACCity(MerchModelEntities modelEntities) : base(modelEntities) { }

		public IQueryable<City> GetAllCities()
		{
			return from cit in _modelEntities.City select cit;
		}

		public City GetCityById(int cityId)
		{
			return (from cit in _modelEntities.City where cit.Id == cityId select cit).FirstOrDefault();
		}

		public IQueryable<City> GetCitiesByNameInProvince(string cityName, int provinceId)
		{
			return from cit in _modelEntities.City where cit.Name == cityName && cit.Province.Id == provinceId select cit;
		}

		public IQueryable<City> GetCitiesByNameAndOtherIdInProvince(string cityName, int cityId, int provinceId)
		{
			return from cit in _modelEntities.City where cit.Name == cityName && cit.Id != cityId && cit.Province.Id == provinceId select cit;
		}
	}
}
